﻿using System;
using Wedn.Core.Service;
using Wedn.TemplateEngine.UC;

namespace Wedn.Web.UI
{
    public partial class index : FrontPage
    {
        public index() { }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (PageType == "checkurlrewriter")
            {
                Response.Clear();
                Response.Write("OK");
                Response.End();
            }
            if (IsCallback)
                return;
            LoadDefault();

        }
        /// <summary>
        /// 加载通用标签
        /// </summary>
        private void LoadDefault()
        {
            LoadHeader();
            if (HasMaster)
            {
                MasterHelper mh = new MasterHelper((Master)Master);
                mh.Set(Setting.Dict);
                mh.Put("site_title", string.Format("{0}|{1}-Powered by Wedn.Net", Setting.SiteName, Setting.SiteDescription));
                mh.Put("site_url", SiteUrl);
            }
            else
            {
                //如果当前模版没有使用母板页情况;
                th = new TemplateHelper();
                th.Set(Setting.Dict);
                th.Put("site_title", string.Format("{0}|{1}-Powered by Wedn.Net", Setting.SiteName, Setting.SiteDescription));
                th.Put("site_url", SiteUrl);
                th.Render(Response.Output);
            }
        }
        /// <summary>
        /// 加载Head中数据
        /// </summary>
        private void LoadHeader()
        {
            base.UpdateViewCount();
            base.AddDefaultLanguages();
            base.AddMetaContentType();
            base.SetTitle(string.Format("{0}|{1}-Powered by Wedn.Net", Setting.SiteName, Setting.SiteDescription));
            base.SetMetaKeywords(Setting.MetaKeywords);
            base.SetMetaDescription(Setting.MetaDescription);
            base.AddMetaTag("Generator", Server.HtmlEncode("Wedn.Net"));
        }
    }
}